package com.ea.common.mybatisGenerator;

import java.util.List;

import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.api.dom.java.TopLevelClass;

/**
 * @author linmeixin
 *
 */
public class BaseMapperGeneratorPlugin extends PluginAdapter {

  public boolean validate(List<String> warnings) {
    return true;
  }

  /**
   * 生成dao
   */
  @Override
  public boolean clientGenerated(Interface interfaze,
      TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {

      FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType("EmoAnalyBaseMapper<"
        + introspectedTable.getBaseRecordType() + ">");
    FullyQualifiedJavaType imp = new FullyQualifiedJavaType(
            "com.ea.common.mybatis.EmoAnalyBaseMapper");
    /**
     * 添加 extends EmoAnalyBaseMapper
     */
    interfaze.addSuperInterface(fqjt);

    /**
     * 添加import com.ea.common.mybatis.EmoAnalyBaseMapper
     */
    interfaze.addImportedType(imp);
    /**
     * 方法不需要
     */
    interfaze.getMethods().clear();
    interfaze.getAnnotations().clear();
    return true;
  }

}
